<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header2', 'admin');
?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <meta charset="utf-8"/>
    <title>Metronic | Form Stuff - Form Layouts</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta content="" name="description"/>
    <meta content="" name="author"/>
    <!-- BEGIN GLOBAL MANDATORY STYLES -->
    <!--
    <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css"/>
    -->
    <link href="<?php echo CSS_PATH?>metronic/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
    <link href="<?php echo CSS_PATH?>metronic/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css"/>
    <link href="<?php echo CSS_PATH?>metronic/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link href="<?php echo CSS_PATH?>metronic/uniform/css/uniform.default.css" rel="stylesheet" type="text/css"/>
    <link href="<?php echo CSS_PATH?>metronic/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css"/>
    <!-- END GLOBAL MANDATORY STYLES -->
    <!-- BEGIN PAGE LEVEL STYLES -->
    <link rel="stylesheet" type="text/css" href="<?php echo CSS_PATH?>metronic/select2/select2.css"/>
    <!-- END PAGE LEVEL SCRIPTS -->
    <!-- BEGIN THEME STYLES -->
    <link href="<?php echo CSS_PATH?>metronic/components.css" id="style_components" rel="stylesheet" type="text/css"/>
    <link href="<?php echo CSS_PATH?>metronic/plugins.css" rel="stylesheet" type="text/css"/>
    <link href="<?php echo CSS_PATH?>metronic/layout.css" rel="stylesheet" type="text/css"/>
    <link id="style_color" href="<?php echo CSS_PATH?>metronic/darkblue.css" rel="stylesheet" type="text/css"/>
    <link href="<?php echo CSS_PATH?>metronic/custom.css" rel="stylesheet" type="text/css"/>
    <link href="<?php echo CSS_PATH?>select_xiala.css" rel="stylesheet" type="text/css"/>
    <link href="<?php echo CSS_PATH?>table_form.css" rel="stylesheet" type="text/css" />
    <link href="<?php echo JS_PATH?>images/uploader.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="<?php echo JS_PATH?>calendar/jscal2.css"/>
    <link rel="stylesheet" type="text/css" href="<?php echo JS_PATH?>calendar/border-radius.css"/>
    <link rel="stylesheet" type="text/css" href="<?php echo JS_PATH?>calendar/win2k.css"/>
    <script type="text/javascript" src="<?php echo JS_PATH?>calendar/calendar.js"></script>
    <script type="text/javascript" src="<?php echo JS_PATH?>calendar/lang/en.js"></script>
    <script src="<?php echo JS_PATH?>PCASClass.js"></script>
    <!-- END THEME STYLES -->
    <link rel="shortcut icon" href="favicon.ico"/>
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed page-quick-sidebar-over-content ">
<!-- BEGIN HEADER -->
<!-- BEGIN CONTAINER -->
<div class="page-container">
    <!-- BEGIN CONTENT -->
    <div class="page-content-wrapper">
        <div>
            <!-- BEGIN PAGE CONTENT-->
            <div class="row">
                <div class="col-xs-2">
                    <div class="tabbable-line boxless tabbable-reversed">
                        <div class="tab-content">
                            <div >
                                <div style="background-color: #e2e8f7;padding: 9px;color:black;">
                                    <h1 class="text-center"><?php echo $patients_data[0]['patient_name']?></h1><br>
                                    <p class="text-center">
                                        <?php echo $patients_data[0]['sex']?>
                                        <?php echo $patients_data[0]['age']?>
                                        <?php echo $patients_data[0]['address']?>
                                    </p>
                                    <p class="text-center">
                                        <h>电话:<?php echo $patients_data[0]['phone']?></h>

                                    </p>
                                    <p class="text-center">
                                        <h>档案号：</h><?php echo $patients_data[0]['archives_num']?>
                                    </p>
                                </div>
                                <?php if(is_array($data)){foreach($data as $v){?>
                                    <p class='text-center' style="background-color:#5a99fb;padding:13px;margin-top: 4px;border-radius:6px !important;">
                                        <a style="color:white" href="javascript:editRecord('<?php echo $v['id']?>')"><?php echo $v['clinic_time']?></a>
                                    </p>

                                <?php }} ?>


                            </div>
                        </div>
                    </div>

                </div>
                <div class="col-xs-10">
                    <div class="tabbable-line boxless tabbable-reversed">
                        <div class="tab-content">
                            <div class="tab-pane active" id="tab_0">
                                <div class="">

                                    <div class="portlet-body form">
                                        <h><strong>查看病历：</strong></h>
                                        <h3 style="float:right;margin-right: 100px"><a href="/boneDatabase/index.php?m=admin&c=boneDatabase&a=patients_info">回到主页</a></h3>
                                        <ul id="myTabs" class="nav nav-tabs" role="tablist">
                                            <li role="presentation" class="active">
                                                <a href="#bone" id="bone-tab" role="tab" data-toggle="tab" aria-controls="bone" aria-expanded="true">病史输入</a>
                                            </li>
                                            <li role="presentation" >
                                                <a href="#home" id="home-tab" role="tab" data-toggle="tab" aria-controls="home" >体格检查</a>
                                            </li>
                                            <li role="presentation">
                                                <a href="#profile" role="tab" id="profile-tab" data-toggle="tab" aria-controls="profile">影像诊断</a>
                                            </li>

                                        </ul>
                                        <!-- BEGIN FORM-->
                                        <form name="myform" action="?m=admin&c=boneDatabase&a=medicalRecord_editdo" method="post" id="myform" class="form-horizontal">
                                            <div class="form-body">
                                                <fieldset disabled>
                                                    <div id="myTabContent" class="tab-content">
                                                        <div role="tabpanel" class="tab-pane fade in active" id="bone" aria-labelledby="bone-tab">
                                                            <div class="col-xs-6">
                                                                <div class="form-group">
                                                                    <label class="col-xs-12 pullleft">就诊时间
                                                                        <span class="glyphicon glyphicon-star star"  style="color:#618ee2" aria-hidden="true"></span>
                                                                    </label>
                                                                    <div class="col-xs-12">
                                                                        <input type="text" value="<?php echo $medical_record_data['clinic_time'] ?>" name="clinic_time" id="clinic_time" size="10" class="selectadd date" >
                                                                        <script type="text/javascript">
                                                                            Calendar.setup({
                                                                                weekNumbers: true,
                                                                                inputField : "clinic_time",
                                                                                trigger    : "clinic_time",
                                                                                dateFormat: "%Y-%m-%d",
                                                                                showTime: false,
                                                                                minuteStep: 1,
                                                                                onSelect   : function() {this.hide();}
                                                                            });
                                                                        </script>
                                                                    </div>

                                                                </div>
                                                                <div class="form-group">
                                                                    <label class="col-xs-12 pullleft">
                                                                        医院号
                                                                        <span class="glyphicon glyphicon-star star"   aria-hidden="true"></span>
                                                                        <select name="hospital_num" id="hospital_num"  style="width:110px" >
                                                                            <option value="" selected="">请选择</option>
                                                                            <?php if(is_array($hospital_data) ){foreach($hospital_data as $v){?>
                                                                                <option value="<?php echo $v['hospitalnum'] ?>" <?php if($medical_record_data['hospital_num'] == $v['hospitalnum']){ echo 'selected';}?> >
                                                                                    <?php echo $v['hospitalnum'] ?>
                                                                                </option>
                                                                            <?php }} ?>
                                                                        </select>
                                                                    </label>

                                                                </div>
                                                                <div class="form-group">
                                                                    <label class="col-xs-12 pullleft">
                                                                        主诉<span class="glyphicon glyphicon-star star"  aria-hidden="true"></span>
                                                                    </label>
                                                                    <div class="col-xs-12">
                                                                        <input type="text" name="chief_complaint" id="chief_complaint"  class="form-control input-circle" value="<?php echo $medical_record_data['chief_complaint']?>">

                                                                    </div>
                                                                </div>
                                                                <div class="form-group">
                                                                    <label class="col-xs-12 pullleft">
                                                                        既往史<span class="glyphicon glyphicon-star star"   aria-hidden="true"></span>
                                                                        <select name="previous_history" id="previous_history" style="border-radius: 8px !important;">
                                                                            <option value="有" <?php if($medical_record_data['previous_history']=='有'){ echo 'selected';}?> >有</option>
                                                                            <option value="无" <?php if($medical_record_data['previous_history']=='无'){ echo 'selected';}?>>无</option>
                                                                        </select>
                                                                    </label>
                                                                </div>
                                                                <div class="form-group">
                                                                    <div class="col-xs-12">
                                                                        <textarea style="margin-top: -10px;" type="text" name="previous_history_desc" id="previous_history_desc"  class="form-control testarea" rows="3" placeholder="描述"  value="<?php echo $medical_record_data['previous_history_desc']?>"><?php echo $medical_record_data['previous_history_desc']?></textarea>
                                                                    </div>
                                                                </div>
                                                                <div class="form-group">
                                                                    <label class="col-xs-12 pullleft">家族史
                                                                        <span class="glyphicon glyphicon-star star"   aria-hidden="true"></span>
                                                                        <select name="family_history" id="family_history" style="border-radius: 8px !important;">
                                                                            <option value="有" <?php if($medical_record_data['family_history']=='有'){ echo 'selected';}?> >有</option>
                                                                            <option value="无" <?php if($medical_record_data['family_history']=='无'){ echo 'selected';}?>>无</option>
                                                                        </select>
                                                                    </label>
                                                                </div>
                                                                <div class="form-group">
                                                                    <div class="col-xs-12">
                                                                        <textarea style="margin-top: -10px;" class="form-control testarea" rows="3" name="family_history_desc" id="family_history_desc"  placeholder="描述"  value="<?php echo $medical_record_data['family_history_desc']?>"><?php echo $medical_record_data['family_history_desc']?></textarea>
                                                                    </div>
                                                                </div>
                                                                <div class="form-group">
                                                                    <label class="col-xs-12 pullleft">过敏史
                                                                        <span class="glyphicon glyphicon-star star"   aria-hidden="true"></span>
                                                                        <select name="allergic_history" id="allergic_history" style="border-radius: 8px !important;">
                                                                            <option value="有" <?php if($medical_record_data['allergic_history']=='有'){ echo 'selected';}?> >有</option>
                                                                            <option value="无" <?php if($medical_record_data['allergic_history']=='无'){ echo 'selected';}?>>无</option>
                                                                        </select>

                                                                    </label>
                                                                </div>
                                                                <div class="form-group">
                                                                    <div class="col-xs-12">
                                                                        <textarea style="margin-top: -10px;" class="form-control testarea" rows="3" name="allergic_history_desc" id="allergic_history_desc" value="<?php echo $medical_record_data['allergic_history_desc']?>" placeholder="描述"><?php echo $medical_record_data['allergic_history_desc']?></textarea>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="col-xs-6">
                                                                <div class="form-group">
                                                                    <label class="col-xs-12 pullleft">兼用药情况
                                                                        <span class="glyphicon glyphicon-star star"   aria-hidden="true"></span>
                                                                        <select name="drug_use" id="drug_use" style="border-radius: 8px !important;">
                                                                            <option value="有" <?php if($medical_record_data['drug_use']=='有'){ echo 'selected';}?> >有</option>
                                                                            <option value="无" <?php if($medical_record_data['drug_use']=='无'){ echo 'selected';}?>>无</option>
                                                                        </select>
                                                                    </label>
                                                                </div>
                                                                <div class="form-group">
                                                                    <div class="col-xs-12" style="background-color:#eef2f9;" id="drug_use_div">
                                                                        <input type="hidden" id='drug_use_reason' name="drug_use_reason" value=""/>
                                                                        <input type="hidden" id="drug_name" name="drug_name" value=""/>
                                                                        <input type="hidden" id="use_way" name="use_way" value=""/>
                                                                        <input type="hidden"  id="start_time" name='start_time' value=""  />


                                                                        <table id="drug_use_table" class="datatable-table" style="min-height:30px;margin-top: 20px" cellspacing="0" width="90%" >
                                                                            <thead>
                                                                            <tr>
                                                                                <th>使用原因</th>
                                                                                <th>药物名称</th>
                                                                                <th>用法用量</th>
                                                                                <th>开始用药时间</th>
                                                                            </tr>
                                                                            </thead>
                                                                            <tbody>
                                                                            <?php if(is_array($drug_use)){$count=0;foreach($drug_use as $drug){?>
                                                                                <tr>
                                                                                    <td>
                                                                                        <textarea type="text" class="short-input drugreason datables"><?php echo $drug["drug_use_reason"]?></textarea>
                                                                                    </td>

                                                                                    <td>
                                                                                        <textarea type="text" class="short-input drugname datables"><?php echo $drug["drug_name"]?></textarea>
                                                                                    </td>
                                                                                    <td>
                                                                                        <textarea type="text" class="short-input useway datables"><?php echo $drug["use_way"]?></textarea>
                                                                                    </td>
                                                                                    <td>
                                                                                        <textarea type="text" class="short-input time datables"><?php echo $drug["start_time"]?></textarea>
                                                                                    </td>

                                                                                </tr>
                                                                                <?php $count++;}} ?>
                                                                            </tbody>
                                                                        </table>
                                                                        <div class="text-center" id="buttonadd">
                                                                            <button id="drug_use_addbtn" class="btn btn-circle blue">添加</button>
                                                                            <button id="drug_use_delbtn" class="btn btn-circle blue">删除</button>
                                                                        </div>
                                                                    </div>
                                                                </div>

                                                                <div class="form-group">
                                                                    <label class="col-xs-12 pullleft" style="height:56px">西医诊断
                                                                        <span class="glyphicon glyphicon-star star"  aria-hidden="true"></span>
                                                                    </label>
                                                                    <div class="col-xs-12" >
                                                                        <textarea name="western_diagnose" id="western_diagnose"  class="form-control testarea" ><?php echo $medical_record_data['western_diagnose']?></textarea>
                                                                    </div>
                                                                </div>
                                                                <div class="form-group">
                                                                    <label class="col-xs-12 pullleft" style="height:56px">中医诊断
                                                                        <span class="glyphicon glyphicon-star star"   aria-hidden="true"></span>
                                                                    </label>
                                                                    <div class="col-xs-12">
                                                                        <textarea name="chinese_diagnose" id="chinese_diagnose"  class="form-control testarea" ><?php echo $medical_record_data['chinese_diagnose']?></textarea>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div role="tabpanel" class="tab-pane fade" id="home"  aria-labelledby="home-tab">
                                                            <div class="form-group">
                                                                <label class="col-xs-12 pullleft">身高</label>
                                                                <div class="col-xs-6">
                                                                    <input type="text" name="height" id="height"  class="form-control input-circle" value="<?php echo $medical_record_data['height']?>">
                                                                </div>
                                                                <div class="col-xs-6">
                                                                    cm
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label class="col-xs-12 pullleft">体重</label>
                                                                <div class="col-xs-6">
                                                                    <input type="text" name="weight" id="weight"  class="form-control input-circle" value="<?php echo $medical_record_data['weight']?>">
                                                                </div>
                                                                <div class="col-xs-6">
                                                                    kg
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label class="col-xs-12 pullleft">体温</label>
                                                                <div class="col-xs-6">
                                                                    <input type="text" name="body_temperature" id="body_temperature"  class="form-control input-circle" value="<?php echo $medical_record_data['body_temperature']?>">
                                                                </div>
                                                                <div class="col-xs-6">
                                                                    ℃
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label class="col-xs-12 pullleft">心率</label>
                                                                <div class="col-xs-6">
                                                                    <input type="text" name="heart_rate" id="heart_rate"  class="form-control input-circle" value="<?php echo $medical_record_data['heart_rate']?>">
                                                                </div>
                                                                <div class="col-xs-6">
                                                                    次/分钟
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label class="col-xs-12 pullleft">心律</label>
                                                                <div class="col-xs-6">
                                                                    <select  name="heart_rhythm" class="selectadd">
                                                                        <option value="齐" <?php if($medical_record_data['heart_rhythm']=='齐'){ echo 'selected';}?>>齐</option>
                                                                        <option value="不齐"  <?php if($medical_record_data['heart_rhythm']=='不齐'){ echo 'selected';}?>>不齐</option>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label class="col-xs-12 pullleft">呼吸</label>
                                                                <div class="col-xs-6">
                                                                    <input type="text" name="breath" id="breath"  class="form-control input-circle" value="<?php echo $medical_record_data['breath']?>">
                                                                </div>
                                                                <div class="col-xs-6">
                                                                    次/分钟
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label class="col-xs-12 pullleft">血压</label>
                                                                <div class="col-xs-3">
                                                                    <input type="text" name="sitting_blood_pressure"   class="form-control input-circle" value="<?php echo $medical_record_data['sitting_blood_pressure']?>" placeholder="坐位">
                                                                </div>
                                                                <h style="float:left;margin-top: 9px;">/</h>
                                                                <div class="col-xs-3">
                                                                    <input type="text" name="leftarm_blood_pressure"   class="form-control input-circle" value="<?php echo $medical_record_data['leftarm_blood_pressure']?>" placeholder="左臂">
                                                                </div>
                                                                <div class="col-xs-4">
                                                                    mmHg
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div role="tabpanel" class="tab-pane fade" id="profile" aria-labelledby="profile-tab">
                                                            <div class="form-group" style="margin-top: 30px">
                                                                <label class="col-xs-1 control-label">X片</label>
                                                                <div class="col-xs-11">
                                                                    <input type="hidden" name="X_ray" id="X_ray"  value=""/>
                                                                    <input type="hidden" name="X_ray_hipjoint" id="X_ray_hipjoint" value=""/>
                                                                    <input type="hidden" name="X_raylink" id="X_raylink" value=""/>
                                                                    <input type="hidden" name="X_raydesc" id="X_raydesc" value=""/>


                                                                    <table id="X_ray_table" class="datatable-table" style="min-height:30px;" cellspacing="0" width="90%">
                                                                        <thead>
                                                                        <tr>
                                                                            <th></th>
                                                                            <th></th>
                                                                            <th></th>
                                                                            <th></th>
                                                                            <th></th>
                                                                        </tr>
                                                                        </thead>
                                                                        <tbody>
                                                                        <?php if(is_array($X_rayAll)){$count=0;foreach($X_rayAll as $X_rayAll ){?>
                                                                            <tr>
                                                                                <td>
                                                                                    检测结果:
                                                                                    <select class="X_ray datablesadd"  >
                                                                                        <option value="正常" <?php if($X_rayAll["X_ray"]=='正常'){ echo 'selected';}?>>正常</option>
                                                                                        <option value="异常" <?php if($X_rayAll["X_ray"]=='异常'){ echo 'selected';}?>>异常</option>
                                                                                    </select>
                                                                                </td>

                                                                                <td>
                                                                                    髋关节部位:
                                                                                    <select class="X_ray_hipjoint datablesadd"  >
                                                                                        <option value="部位1" <?php if($X_rayAll["X_ray_hipjoint"]=='部位1'){ echo 'selected';}?>>部位1</option>
                                                                                        <option value="部位2" <?php if($X_rayAll["X_ray_hipjoint"]=='部位2'){ echo 'selected';}?>>部位2</option>
                                                                                    </select>
                                                                                </td>

                                                                                <td>
                                                                                    X_ray片:
                                                                                    <textarea type="text" class="short-input small datablesadd" count=<?php echo $count;?>   id="X_raypicurl_<?php echo $count;?>" ><?php echo $X_rayAll["X_raylink"]?></textarea>
                                                                                </td>

                                                                                <td>
                                                                                    <button id="X_ray_btn_<?php echo $count;?>" class="button" style="font-size:12px;width: 45px;" >上传</button>
                                                                                    <div id="X_raypic_img_<?php echo $count;?>" class="upload-box datablesadd"></div>
                                                                                </td>

                                                                                <td>
                                                                                    描述
                                                                                    <textarea type="text" class="short-input X_raydesc datablesadd"><?php echo $X_rayAll["X_raydesc"]?></textarea>
                                                                                </td>

                                                                            </tr>
                                                                            <?php $count++;}} ?>
                                                                        </tbody>
                                                                    </table>
                                                                    <div class="text-center">
                                                                        <button id="X_ray_addbtn" class="btn btn-circle blue">添加</button>
                                                                        <button id="X_ray_delbtn" class="btn btn-circle red">删除</button>
                                                                    </div>

                                                                </div>
                                                            </div>
                                                            <div class="form-group" style="margin-top: 50px">
                                                                <label class="col-xs-1 control-label">CT片</label>
                                                                <div class="col-xs-11">
                                                                    <input type="hidden" name="CT" id="CT"  value=""/>
                                                                    <input type="hidden" name="CT_hipjoint" id="CT_hipjoint" value=""/>
                                                                    <input type="hidden" name="CT_link" id="CT_link" value=""/>
                                                                    <input type="hidden" name="CT_desc" id="CT_desc"  value=""/>


                                                                    <table id="CT_table" class="datatable-table" style="min-height:30px;" cellspacing="0" width="90%">
                                                                        <thead>
                                                                        <tr>
                                                                            <th></th>
                                                                            <th></th>
                                                                            <th></th>
                                                                            <th></th>
                                                                            <th></th>
                                                                        </tr>
                                                                        </thead>
                                                                        <tbody>
                                                                        <?php if(is_array($CTAll)){$count=0;foreach($CTAll as $CTAll ){?>
                                                                            <tr>
                                                                                <td>
                                                                                    检测结果:
                                                                                    <select class="CT datablesadd"  >
                                                                                        <option value="正常" <?php if($CTAll["CT"]=='正常'){ echo 'selected';}?>>正常</option>
                                                                                        <option value="异常" <?php if($CTAll["CT"]=='异常'){ echo 'selected';}?>>异常</option>
                                                                                    </select>
                                                                                </td>

                                                                                <td>
                                                                                    髋关节部位:
                                                                                    <select class="CT_hipjoint datablesadd"   >
                                                                                        <option value="部位1" <?php if($CTAll["CT_hipjoint"]=='部位1'){ echo 'selected';}?>>部位1</option>
                                                                                        <option value="部位2" <?php if($CTAll["CT_hipjoint"]=='部位2'){ echo 'selected';}?>>部位2</option>
                                                                                    </select>
                                                                                </td>

                                                                                <td>
                                                                                    CT片:
                                                                                    <textarea type="text" class="short-input small datablesadd" count=<?php echo $count;?>   id="CTpicurl_<?php echo $count;?>"><?php echo $CTAll["CTlink"]?></textarea>
                                                                                </td>

                                                                                <td>
                                                                                    <button id="CT_btn_<?php echo $count;?>" class="button" style="font-size:12px;width: 45px;">上传</button>
                                                                                    <div id="CTpic_img_<?php echo $count;?>" class="upload-box datablesadd"></div>
                                                                                </td>

                                                                                <td>
                                                                                    描述
                                                                                    <textarea type="text" class="short-input CT_desc datablesadd"  ><?php echo $CTAll["CTdesc"]?></textarea>
                                                                                </td>

                                                                            </tr>
                                                                            <?php $count++;}} ?>
                                                                        </tbody>
                                                                    </table>
                                                                    <div class="text-center">
                                                                        <button id="CT_addbtn" class="btn btn-circle blue">添加</button>
                                                                        <button id="CT_delbtn" class="btn btn-circle red">删除</button>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="form-group" style="margin-top: 50px" >
                                                                <label class="col-xs-1 control-label">MRI</label>
                                                                <div class="col-xs-11">
                                                                    <input type="hidden" name="MRI" id="MRI"   value=""/>
                                                                    <input type="hidden" name="MRI_hipjoint" id="MRI_hipjoint" value=""/>
                                                                    <input type="hidden" name="MRI_link" id="MRI_link" value=""/>
                                                                    <input type="hidden" name="MRI_desc" id="MRI_desc"  value=""/>


                                                                    <table id="MRI_table" class="datatable-table" style="min-height:30px;" cellspacing="0" width="90%">
                                                                        <thead>
                                                                        <tr>
                                                                            <th></th>
                                                                            <th></th>
                                                                            <th></th>
                                                                            <th></th>
                                                                            <th></th>
                                                                        </tr>
                                                                        </thead>
                                                                        <tbody>
                                                                        <?php if(is_array($MRIAll)){$count=0;foreach($MRIAll as $MRIAll ){?>
                                                                            <tr>
                                                                                <td>
                                                                                    检测结果:
                                                                                    <select class="MRI datablesadd"  >
                                                                                        <option value="正常" <?php if($MRIAll["MRI"]=='正常'){ echo 'selected';}?>>正常</option>
                                                                                        <option value="异常" <?php if($MRIAll["MRI"]=='异常'){ echo 'selected';}?>>异常</option>
                                                                                    </select>
                                                                                </td>

                                                                                <td>
                                                                                    髋关节部位:
                                                                                    <select class="MRI_hipjoint datablesadd"  >
                                                                                        <option value="部位1" <?php if($MRIAll["MRI_hipjoint"]=='部位1'){ echo 'selected';}?>>部位1</option>
                                                                                        <option value="部位2" <?php if($MRIAll["MRI_hipjoint"]=='部位2'){ echo 'selected';}?>>部位2</option>
                                                                                    </select>
                                                                                </td>

                                                                                <td>
                                                                                    MRI:
                                                                                    <textarea class="short-input small datablesadd" count=<?php echo $count;?>   id="MRIpicurl_<?php echo $count;?>" ><?php echo $MRIAll["MRIlink"]?></textarea>
                                                                                </td>

                                                                                <td>
                                                                                    <button id="MRI_btn_<?php echo $count;?>" class="button" style="font-size:12px;width: 45px;">上传</button>
                                                                                    <div id="MRIpic_img_<?php echo $count;?>" class="upload-box datablesadd"></div>
                                                                                </td>

                                                                                <td>
                                                                                    描述
                                                                                    <textarea type="text"  class="short-input MRI_desc datablesadd"   ><?php echo $MRIAll["MRIdesc"]?></textarea>
                                                                                </td>

                                                                            </tr>
                                                                            <?php $count++;}} ?>
                                                                        </tbody>
                                                                    </table>
                                                                    <div class="text-center">
                                                                        <button id="MRI_addbtn" class="btn btn-circle blue">添加</button>
                                                                        <button id="MRI_delbtn" class="btn btn-circle red">删除</button>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                            </div>
                                            <div class="form-actions">
                                                <div class="row">
                                                    <input type="hidden" name="medical_id" value="<?php echo $_GET['id'] ?>" >
                                                    <input type="hidden" name="patients_id" value="<?php echo $patients_id ?>" >
                                                    <div class="col-xs-offset-8 col-xs-12">
                                                        <a  class="btn btn-circle blue" style="width: 11%;" onclick="history.go(-1)">返回</a>
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
                                                </fieldset>

                                        <!-- END FORM-->
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- END PAGE CONTENT-->
            </div>
        </div>
        <!-- END CONTENT -->
    </div>
    <!-- [if lt IE 9]> -->
    <script src="<?php echo CSS_PATH?>metronic/respond.min.js"></script>
    <script src="<?php echo CSS_PATH?>metronic/excanvas.min.js"></script>
    <!-- <![endif] -->
    <!-- <script type="text/javascript" src="jquery-1.8.0.min.js"></script> -->


    <script src="<?php echo CSS_PATH?>metronic/jquery.min.js" type="text/javascript"></script>
    <script src="<?php echo CSS_PATH?>metronic/jquery-migrate.min.js" type="text/javascript"></script>
    <!-- IMPORTANT! Load jquery-ui.min.js before bootstrap.min.js to fix bootstrap tooltip conflict with jquery ui tooltip -->
    <script src="<?php echo CSS_PATH?>metronic/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
    <script src="<?php echo CSS_PATH?>metronic/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="<?php echo CSS_PATH?>metronic/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js" type="text/javascript"></script>
    <script src="<?php echo CSS_PATH?>metronic/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
    <script src="<?php echo CSS_PATH?>metronic/jquery.blockui.min.js" type="text/javascript"></script>
    <script src="<?php echo CSS_PATH?>metronic/jquery.cokie.min.js" type="text/javascript"></script>
    <script src="<?php echo CSS_PATH?>metronic/uniform/jquery.uniform.min.js" type="text/javascript"></script>
    <script src="<?php echo CSS_PATH?>metronic/bootstrap-switch/js/bootstrap-switch.min.js" type="text/javascript"></script>
    <!-- END CORE PLUGINS -->
    <!-- BEGIN PAGE LEVEL PLUGINS -->
    <script type="text/javascript" src="<?php echo CSS_PATH?>metronic/select2/select2.min.js"></script>
    <!-- END PAGE LEVEL PLUGINS -->
    <!-- BEGIN PAGE LEVEL SCRIPTS -->
    <script src="<?php echo CSS_PATH?>metronic/metronic.js" type="text/javascript"></script>
    <script src="<?php echo CSS_PATH?>metronic/layout.js" type="text/javascript"></script>
    <script src="<?php echo CSS_PATH?>metronic/quick-sidebar.js" type="text/javascript"></script>
    <script src="<?php echo CSS_PATH?>metronic/demo.js" type="text/javascript"></script>
    <script src="<?php echo CSS_PATH?>metronic/form-samples.js"></script>
    <script src="<?php echo JS_PATH?>formvalidator.js"></script>
    <script src="<?php echo JS_PATH?>formvalidatorregex.js"></script>
    <script src="<?php echo JS_PATH?>images/fine-uploader.core.min.js"></script>
    <script src="<?php echo JS_PATH?>images/uploader.js"></script>
    <script src="<?php echo JS_PATH?>datatables/jquery.dataTables.min.js"></script>
    <script src="<?php echo JS_PATH?>datatables/dataTables.scroller.min.js"></script>
    <script src="<?php echo JS_PATH?>datatables/table.js"></script>
    <!-- END PAGE LEVEL SCRIPTS -->
    <script type="text/javascript">
        function addRecord(id){
            location.href ='?m=admin&c=boneDatabase&a=medicalRecord_add&patients_id='+id+'&pc_hash='+pc_hash+'&goback='+BASE64.encode(location.search);
        }
        function editRecord(id){
            location.href ='?m=admin&c=boneDatabase&a=medicalRecord_edit&id='+id+'&pc_hash='+pc_hash+'&goback='+BASE64.encode(location.search);
        }
        function dodelete(id){

            location.href ='?m=admin&c=boneDatabase&a=medicalRecord_delete&id='+id+'&pc_hash='+pc_hash+'&patients_id=<?php echo  $patients_id?>'
            +'&goback='+BASE64.encode(location.search);
        }

    </script>
    <script type="text/javascript" src="statics/js/base64.js"></script>
    <script>
        jQuery(document).ready(function() {
            // initiate layout and plugins
            Metronic.init(); // init metronic core components
            Layout.init(); // init current layout
            QuickSidebar.init(); // init quick sidebar
            Demo.init(); // init demo features
            FormSamples.init();
        });
    </script>
    <script type="text/javascript">
        $("#previous_history").change(function(){

            var v = $('#previous_history').val();
            if (v =="有"){
                $("#previous_history_desc").show();

            }else if(v =="无"){
                $("#previous_history_desc").hide();
            }
        });
        $("#previous_history").change();
        //family_history allergic_history
        $("#family_history").change(function(){

            var v = $('#family_history').val();
            if (v =="有"){
                $("#family_history_desc").show();

            }else if(v =="无"){
                $("#family_history_desc").hide();
            }
        });
        $("#family_history").change();
        //
        $("#allergic_history").change(function(){

            var v = $('#allergic_history').val();
            if (v =="有"){
                $("#allergic_history_desc").show();

            }else if(v =="无"){
                $("#allergic_history_desc").hide();
            }
        });
        $("#allergic_history").change();
        /////drug_use
        $("#drug_use").change(function(){

            var v = $('#drug_use').val();
            if (v =="有"){
                $('#drug_use_table_wrapper').show();
                $('#drug_use_table').show();
                $('#buttonadd').show();

            }else if(v =="无"){
                $('#drug_use_table_wrapper').hide();
                $('#drug_use_table').hide();
                $('#buttonadd').hide();
            }
        });
        $("#drug_use").change();

        $(document).ready(function() {

            $.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});

            $("#hospital_num").formValidator({onshow:"<?php echo L('请输入').L('医院号')?>",onfocus:"<?php echo L('请输入').L('医院号')?>"}).inputValidator({min:1,max:30,onerror:"<?php echo L('请输入').L('医院号')?>"});
            $("#chief_complaint").formValidator({onshow:"<?php echo L('请输入').L('主诉')?>",onfocus:"<?php echo L('请输入').L('主诉')?>"}).inputValidator({min:1,max:30,onerror:"<?php echo L('请输入').L('主诉')?>"});
            $("#western_diagnose").formValidator({onshow:"<?php echo L('请输入').L('西医诊断')?>",onfocus:"<?php echo L('请输入').L('西医诊断')?>"}).inputValidator({min:1,max:200,onerror:"<?php echo L('请输入').L('西医诊断')?>"});
            $("#chinese_diagnose").formValidator({onshow:"<?php echo L('请输入').L('中医诊断')?>",onfocus:"<?php echo L('请输入').L('中医诊断')?>"}).inputValidator({min:1,max:200,onerror:"<?php echo L('请输入').L('中医诊断N')?>"});
            $("#clinic_time").formValidator({onshow:"<?php echo L('请选择').L('就诊时间')?>",onfocus:"<?php echo L('请选择').L('就诊时间')?>"}).inputValidator({min:1,max:30,onerror:"<?php echo L('请选择').L('就诊时间')?>"}).ajaxValidator({
                type : "get",
                url : "",
                data :"m=admin&c=boneDatabase&a=check_clinic_time_ajx&patients_id=<?php echo $patients_data['id']?>&medicalrecord_id=<?php echo $medical_record_data['id']?>",
                datatype : "html",
                async:'false',
                success : function(data){
                    if( data == "1" )
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                },
                buttons: $("#dosubmit"),
                onerror : "<?php echo L('就诊时间已经存在')?>",
                onwait : "<?php echo L('检查中')?>"

            })

            //X_RAY编辑
            var count = getMaxTrCount("#X_ray_table .small") ;
            console.log(count);
            for(var i=0;i<=count;i++){
                imageUploaderWrapper({
                    prefix:"<?php echo pc_base::load_config('system', 'upload_prefix')?>",
                    launch_button:$('#X_ray_btn_'+i),
                    image_container:$('#X_raypic_img_'+i),
                    url_input:$('#X_raypicurl_'+i),
                });
            }
            //CT编辑
            var count = getMaxTrCount("#CT_table .small") ;
            console.log(count);
            for(var i=0;i<=count;i++){
                imageUploaderWrapper({
                    prefix:"<?php echo pc_base::load_config('system', 'upload_prefix')?>",
                    launch_button:$('#CT_btn_'+i),
                    image_container:$('#CTpic_img_'+i),
                    url_input:$('#CTpicurl_'+i),
                });
            }
            //MRI编辑
            var count = getMaxTrCount("#MRI_table .small") ;
            console.log(count);
            for(var i=0;i<=count;i++){
                imageUploaderWrapper({
                    prefix:"<?php echo pc_base::load_config('system', 'upload_prefix')?>",
                    launch_button:$('#MRI_btn_'+i),
                    image_container:$('#MRIpic_img_'+i),
                    url_input:$('#MRIpicurl_'+i),
                });
            }


            //药用情况
            var dt_drug =dataTableWrapper({
                table : $("#drug_use_table"),
                add_btn : $("#drug_use_addbtn"),
                del_btn : $("#drug_use_delbtn"),
                add_row_before_func : function(){
                    var count = getMaxTrCount("#drug_use_table.small") + 1;

                    return [
                        '<textarea type="text"  class="short-input drugreason datables"  value=""></textarea>',

                        '<textarea type="text"  class="short-input  drugname datables"   value=""></textarea>',
                        '<textarea type="text"  class="short-input  useway datables"    value=""></textarea>',

                        '<textarea type="text"  class="short-input time datables"  placeholder="格式：2016-01-01"   value=""></textarea> '
                    ];}

            });
//x-ray
            var dt_X_ray = dataTableWrapper({
                table : $("#X_ray_table"),
                add_btn : $("#X_ray_addbtn"),
                del_btn : $("#X_ray_delbtn"),
                add_row_before_func : function(){
                    var count = getMaxTrCount("#X_ray_table .small") + 1;
                    return [
                        '检测结果:<select  class="X_ray datablesadd" > <option value="正常">正常</option><option value="异常">异常</option></select>',
                        '髋关节部位:<select class="X_ray_hipjoint datablesadd"> <option>部位1</option><option>部位2</option></select>',
                        'X_ray片:<textarea  class="short-input small datablesadd" count='+count+'  id="X_raypicurl_'+count+'" value=""></textarea>',
                        '<button id="X_ray_btn_'+count+'" class="button" style="font-size:12px;width: 45px;">上传</button><div id="X_raypic_img_'+count+'" class="upload-box datablesadd"></div>',
                        '描述<textarea type="text"  class="short-input X_raydesc datablesadd"  value=""></textarea>'


                    ];},
                add_row_after_func : function(){
                    var i = getMaxTrCount("#X_ray_table .small");
                    imageUploaderWrapper({
                        prefix:"<?php echo pc_base::load_config('system', 'upload_prefix')?>",
                        launch_button:$('#X_ray_btn_'+i),
                        image_container:$('#X_raypic_img_'+i),
                        url_input:$('#X_raypicurl_'+i),
                    });

                }

            });
//	CT片
            var dt_CT = dataTableWrapper({
                table : $("#CT_table"),
                add_btn : $("#CT_addbtn"),
                del_btn : $("#CT_delbtn"),
                add_row_before_func : function(){
                    var count = getMaxTrCount("#CT_table .small") + 1;
                    var hidden = (count>0)?" style='visibility:hidden' ":"";
                    return [
                        '检测结果：<select class="CT datablesadd"> <option value="正常">正常</option><option value="异常">异常</option></select>',
                        '髋关节部位：<select class="CT_hipjoint datablesadd"> <option>部位1</option><option>部位2</option></select>',
                        'CT片<textarea type="text"  class="short-input small datablesadd" count='+count+'  id="CTpicurl_'+count+'" value=""></textarea>',
                        '<button id="CT_btn_'+count+'" class="button" style="font-size:12px;width: 45px;">上传</button><div id="CTpic_img_'+count+'" class="upload-box datablesadd"></div>',
                        '描述<textarea type="text" class="short-input CT_desc datablesadd"   value=""></textarea>'


                    ];},
                add_row_after_func : function(){
                    var i = getMaxTrCount("#CT_table .small");
                    imageUploaderWrapper({
                        prefix:"<?php echo pc_base::load_config('system', 'upload_prefix')?>",
                        launch_button:$('#CT_btn_'+i),
                        image_container:$('#CTpic_img_'+i),
                        url_input:$('#CTpicurl_'+i),
                    });

                }

            });
//	MRI
            var dt_MRI = dataTableWrapper({
                table : $("#MRI_table"),
                add_btn : $("#MRI_addbtn"),
                del_btn : $("#MRI_delbtn"),
                add_row_before_func : function(){
                    var count = getMaxTrCount("#MRI_table .small") + 1;
                    var hidden = (count>0)?" style='visibility:hidden' ":"";
                    return [
                        '检测结果：<select class="MRI datablesadd"> <option value="正常">正常</option><option value="异常">异常</option></select>',
                        '髋关节部位：<select class="MRI_hipjoint datablesadd"> <option>部位1</option><option>部位2</option></select>',
                        'MRI<textarea type="text"  class="short-input small datablesadd" count='+count+'  id="MRIpicurl_'+count+'" value=""></textarea>',
                        '<button id="MRI_btn_'+count+'" class="button" style="font-size:12px;width: 45px;">上传</button><div id="MRIpic_img_'+count+'" class="upload-box datablesadd"></div>',
                        '描述<textarea type="text" class="short-input MRI_desc datablesadd"  value=""></textarea>'


                    ];},
                add_row_after_func : function(){
                    var i = getMaxTrCount("#MRI_table .small");
                    imageUploaderWrapper({
                        prefix:"<?php echo pc_base::load_config('system', 'upload_prefix')?>",
                        launch_button:$('#MRI_btn_'+i),
                        image_container:$('#MRIpic_img_'+i),
                        url_input:$('#MRIpicurl_'+i),
                    });

                }

            });

            $('#dosubmit').click(function(){
                //药物使用原因
                inputs = dt_drug.$('textarea.drugreason');

                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#drug_use_reason").val(inputs_array.join(','));
                //药物名称
                inputs = dt_drug.$('textarea.drugname');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#drug_name").val(inputs_array.join(','));
                //药物使用方法
                inputs = dt_drug.$('textarea.useway');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#use_way").val(inputs_array.join(','));
                //用药时间
                inputs = dt_drug.$('textarea.time');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#start_time").val(inputs_array.join(','));


                //X_ray
                inputs = dt_X_ray.$('select.X_ray');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#X_ray").val(inputs_array.join(','));
                //X_ray_hipjoint
                inputs = dt_X_ray.$('select.X_ray_hipjoint');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#X_ray_hipjoint").val(inputs_array.join(','));
                //X_raylink
                inputs = dt_X_ray.$('textarea.small');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#X_raylink").val(inputs_array.join(','));
                //	X_raydesc
                inputs = dt_X_ray.$('textarea.X_raydesc');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#X_raydesc").val(inputs_array.join(','));

                //CT
                inputs = dt_CT.$('select.CT');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#CT").val(inputs_array.join(','));
                //CT_hipjoint
                inputs = dt_CT.$('select.CT_hipjoint');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#CT_hipjoint").val(inputs_array.join(','));
                //CTlink
                inputs = dt_CT.$('textarea.small');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#CT_link").val(inputs_array.join(','));
                //	CTdesc
                inputs = dt_CT.$('textarea.CT_desc');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#CT_desc").val(inputs_array.join(','));
                //MRI
                inputs = dt_MRI.$('select.MRI');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#MRI").val(inputs_array.join(','));
                //MRI_hipjoint
                inputs = dt_MRI.$('select.MRI_hipjoint');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#MRI_hipjoint").val(inputs_array.join(','));
                //MRIlink
                inputs = dt_MRI.$('textarea.small');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#MRI_link").val(inputs_array.join(','));
                //	MRIdesc
                inputs = dt_MRI.$('textarea.MRI_desc');
                inputs_array = [];
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].value.length > 0)
                        inputs_array.push(inputs[i].value);
                }
                $("#MRI_desc").val(inputs_array.join(','));



            });

        })
    </script>
    <!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>